
@extends('layouts._order')
@section('main')
    <div class="i_bg bg_color">
        <!--Begin 用户中心 Begin -->
        <div class="m_content">
            @include('layouts._orderleft')
            <div class="m_right" id="addres">
                <div class="mem_tit">我的订单</div>
                <table border="0" class="order_tab" style="width:930px; text-align:center; margin-bottom:30px;" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="20%">订单号</td>
                        <td width="25%">下单时间</td>
                        <td width="15%">订单总金额</td>
                        <td width="25%">订单状态</td>
                        <td width="15%">操作</td>
                    </tr>
                    <tr v-for="v in indent">
                        <td><font color="#ff4e00">@{{ v.order_sn }}</font></td>
                        <td>@{{ v.add_time }}</td>
                        <td>￥@{{ v.order_amount }}</td>
                        <td>@{{ orderStatus[v.order_status] }},@{{ shippingStatus[v.shipping_status] }},@{{ payStatus[v.pay_status] }}</td>
                        <td><a @click="del(v.order_id)">删除订单</a></td>
                    </tr>
                </table>
            </div>
        </div>
        <!--End Footer End -->
    </div>
@endsection
@section('js')
    <script src="{{ mix('js/app.js') }}"></script>
    <script>
        var token = "{{session('admin')}}";
        var user_id = "{{ session('admin_info.user_id') }}";
        new Vue({
            el:'#addres',
            data:{
                indent:[],
                type:'0',
                orderStatus : ['未确认','已确认','已取消','无效','退货'],
                shippingStatus : ['未发货','已发货','已收货','备货中'],
                payStatus : ['未付款','付款中','已付款'],
            },
            methods:{
                del:function(order_id){
                    $.ajax({
                        type:'post',
                        url:"http://shopapi.cn/api/my/delMyIndent",
                        data:{
                            token:token,
                            user_id:user_id,
                            order_id:order_id
                        },
                        success:function(res)
                        {
                            layer.msg(res.msg);
                            window.location.href="/ordercenter/myIndent";
                        }
                    })
                }
            },
            mounted(){
                axios({
                    method: 'get',
                    url: 'http://shopapi.cn/api/my/myIndent',
                    params:{
                        user_id:user_id,
                        token:token,
                        type:this.type
                    }
                })
                .then(
                    (res)=>{
                        this.indent=res.data.data;
                    }
                );
            },
        });
    </script>
@endsection